package com.muyu.controller;

import com.muyu.entity.ResponseEntity;
import com.muyu.entity.UserDbOneEntity;
import com.muyu.entity.UserDbTwoEntity;
import com.muyu.result.ResultResponse;
import com.muyu.service.UserDbService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName: DbUserController
 * @Author: Zirun.Xin
 * @Date: 2025/3/4 9:38
 * @Version: 1.0
 * @Description: 数据库用户控制层
 */
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/dbUser")
public class DbUserController {

    /**
     * 用户数据库业务层
     */
    private final UserDbService userDbService;

    /**
     * 不分页查询db1
     * @return 响应内容
     */
    @GetMapping(value = "/get-users-for-db-one")
    public ResponseEntity<ResultResponse<List<UserDbOneEntity>>> getUserDbOneList() {
        List<UserDbOneEntity> userDbOneList = userDbService.getUserDbOneList();
        return ResponseEntity.ok(ResultResponse.ok(userDbOneList, "查询成功"));
    }

    /**
     * 不分页查询db2
     * @return 响应内容
     */
    @GetMapping(value = "/get-users-for-db-two")
    public ResponseEntity<ResultResponse<List<UserDbTwoEntity>>> getUserDbTwoList() {
        List<UserDbTwoEntity> userDbTwoList = userDbService.getUserDbTwoList();
        return ResponseEntity.ok(ResultResponse.ok(userDbTwoList, "查询成功"));
    }
}
